/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CSISL4pk;

import java.awt.*;
import java.sql.*;
import java.util.*;
/**
 *
 * @author Josh
 */
public class SQLLoadCase {
    ResultSet rs;
    Array a;
    ArrayList rowValues;
    public void SQLLoadCase(){
        
    }
  
    public void getCase(int caseNum){
        
        try{ 
        
            String myDriver = "com.mysql.jdbc.Driver";
            String myUrl = "jdbc:mysql://www.db4free.net:3306/csisl";//www.freesql.org:3306/csisl";//"jdbc:mysql://SQL09.FREEMYSQL.NET:3306/csisl";
            Class.forName(myDriver);
            //Connection conn = DriverManager.getConnection(myUrl, "pablofig","cs2450");
            Connection conn = DriverManager.getConnection(myUrl, "csisaltlake","cs2450");
            // our SQL SELECT query. 
            // if you only need a few columns, specify them by name instead of using "*"
            String nCase = "SELECT *, c.id AS c_id, cp.id AS cp_id, p.id AS p_id FROM cases c, case_to_person cp, person p WHERE caseNum = "+caseNum+" AND case_id = caseNum AND p.id = person_id GROUP BY cp.id";
            System.out.println(nCase);
            // create the java statement
            Statement st = conn.createStatement();

            // execute the query
            rs = st.executeQuery(nCase);
            
            rowValues = new ArrayList();
            
            while (rs.next()) {
                rowValues.add(rs.getString("status"));
            }
            System.out.println(rowValues);

            st.close();
            
        }
        catch(Exception e){
             System.out.println(e);
             
        }
    }
}
